package com.demo.pk.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.demo.pk.common.utils.DataResult;

import com.demo.pk.entity.P17AgentTaskEntity;
import com.demo.pk.service.P17AgentTaskService;

import javax.annotation.Resource;


/**
 * 日常录音品控
 *
 * @author WBB
 * @email *****@mail.com
 * @date 2021-07-18 23:54:16
 */
@RequestMapping("/p17AgentTask")
@RestController
@Api(tags = "日常录音品控")
public class P17AgentTaskController {
    @Resource
    private P17AgentTaskService p17AgentTaskService;

    @ApiOperation(value = "新增")
    @PostMapping("/add")
    @RequiresPermissions("p17AgentTask:add")
    @ResponseBody
    public DataResult add(@RequestBody P17AgentTaskEntity p17AgentTask){
        p17AgentTaskService.save(p17AgentTask);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/delete")
    @RequiresPermissions("p17AgentTask:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        p17AgentTaskService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("/update")
    @RequiresPermissions("p17AgentTask:update")
    @ResponseBody
    public DataResult update(@RequestBody P17AgentTaskEntity p17AgentTask){
        p17AgentTaskService.updateById(p17AgentTask);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("/listByPage")
    @RequiresPermissions("p17AgentTask:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody P17AgentTaskEntity p17AgentTask){
        Page page = new Page(p17AgentTask.getPage(), p17AgentTask.getLimit());
        LambdaQueryWrapper<P17AgentTaskEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(P17AgentTaskEntity::getId, p17AgentTask.getId());
        IPage<P17AgentTaskEntity> iPage = p17AgentTaskService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
